package com.woniuxy.userapp.client;

import com.woniuxy.commons.util.Result;
import com.woniuxy.userapp.client.param.*;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.math.BigDecimal;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Mr.zhou
 * \* Date: 2022/8/6
 * \* Time: 16:49
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */

@FeignClient(contextId = "FrontAccountClient",name="yoga-user", path="/user")
@Component
public interface FrontAccountClient {
    @ApiOperation("根据用户名获取前台账户基本信息")
    @RequestMapping(value = "/frontAccount/FloadByUsername",method = RequestMethod.GET)
    public Result<UserInfo> FloadUserByUsername(@RequestParam String userName);

    @ApiOperation("根据前台账户id获取前台账户信息")
    @RequestMapping(value = "/frontAccount/loadUserByAccountId",method = RequestMethod.GET)
    public Result<FrontAccountInfo> loadUserByAccountId(@RequestParam Integer id);

    @GlobalTransactional(rollbackFor = Exception.class)
    @ApiOperation("account_id,余额,更改账户余额")
    @RequestMapping(value = "/frontAccount/changeMoneyByAccountId",method = RequestMethod.POST)
    public Result changeMoneyByAccountId(@Valid @RequestBody ChangeAccountMoneyInfo changeMoneyInfo);

    @GlobalTransactional(rollbackFor = Exception.class)
    @ApiOperation("超时用户自动扣钱商家自动加钱")
    @RequestMapping(value = "/frontAccount/autoDeductMoney",method = RequestMethod.POST)
    public Result autoDeductMoney(@Valid @RequestBody AutoDeductMoneyInfo autoDeductMoneyInfo);

    @ApiOperation("根据用户id查询余额")
    @GetMapping("/frontAccount/findMoneyByAccountId/{accountId}")
     Result<BigDecimal> findMoneyByAccountId(@PathVariable("accountId") Integer accountId);

    @ApiOperation("教练,商家提现")
    @RequestMapping(value = "/frontAccount/deposit")
    public Result deposit(@RequestBody DepositInfo depositInfo);


    @ApiOperation("前台注册")
    @RequestMapping(value = "/frontAccount/register",method = RequestMethod.POST)
    public Result register(@Validated @RequestBody RegisterInfo registerInfo);


    @ApiOperation("前台账户登录")
    @RequestMapping(value = "/frontLogin",method = RequestMethod.POST)
    public Result login(@RequestBody LoginInfo loginInfo) throws HttpRequestMethodNotSupportedException;

    @ApiOperation("用户充值")
    @RequestMapping(value = "/frontAccount/recharge",method = RequestMethod.POST)
    public Result recharge(@RequestBody RechargeInfo rechargeInfo);
}
